package com.response.controller;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author： yu.Tan
 * @Date: 2020/12/24 16:20
 * @Description:
 */
@RestController
public class PdfController {


    @Autowired
    private RestTemplate restTemplate;


    @RequestMapping(value = "/test_pdf_service", method = RequestMethod.GET)
    @ApiOperation("测试service返回集合")
    public String testPdfService() {

        String urls = "http://ws.sxw.cn/teacher-h5/oa/report/35fe5d50-843a-4772-b6ce-723eca80bc07";
        Map<String, String> map = new HashMap<>();
        map.put("url", urls);
        map.put("oss", "1");
        map.put("fileName", "oa");

        JSONObject object = restTemplate.getForObject("http://portal.sxw.cn/pdf-server/api/pdf/url2pdf?url={url}&oss={oss}&fileName={fileName}", JSONObject.class, map);
        String toJSONString = JSONObject.toJSONString(object);
        return toJSONString;

    }

}
